﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AspfmWinForm
{
    public partial class Form1 : Form
    {
        ClientServices client = new ClientServices("");

        public Form1()
        {
            InitializeComponent();


            client.InitAspfmServices();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            //Aspfm.Dal.IDbHelper IDB = Aspfm.Dal.DbFactory.GetDB();
            //IDB.TransactionBegin();
            //IDB.ExecSql("update aa set a='456' where a='123'");


            //UserIdentity u = new UserIdentity(false);
            //u._uno = "a11";
            //u._uname = "a22";
            //u._dept = "ss";
            //u._loginType = "rr";
            //SessionTool.Clear();
            //SessionTool.SetUserCookie(u);

            client.LoginServices("aa", "bb");
            if (!string.IsNullOrEmpty(client.LoginMiwen))
            {
                //表示登录成功。并把loginmiwen保存起来。
                //下次使用，可以直接ClientServices client1 = new ClientServices(client.LoginMiwen);
                //这样就可以解决总是登录的问题。
            }

            //ClientServices.CreatePostHttpResponse("Aspfm.Login", "Aspfm.Login.Login", "login", null);
            try
            {
                System.Diagnostics.Stopwatch swpage1 = new System.Diagnostics.Stopwatch();
                swpage1.Start();
                for (int i = 0; i < 10000; i++)
                {
                    ClientResult cresult1 = client.CreatePostHttpResponse("Aspfm.Login", "Aspfm.Login.Login", "login", null);
                    if (cresult1.Success && cresult1.WebResultList != null)
                    {

                    }
                }

                swpage1.Stop();
                string str = "<!--耗时{" + swpage1.ElapsedMilliseconds + "}毫秒-->";


                System.Diagnostics.Stopwatch swpage = new System.Diagnostics.Stopwatch();
                swpage.Start();
                ClientResult cresult = client.CreatePostHttpResponse("Aspfm.Login", "Aspfm.Login.Login", "login2", null);
                swpage.Stop();



                str += "<!--耗时{" + swpage.ElapsedMilliseconds + "}毫秒-->";

                //ClientResult cresult = ClientServices.CreatePostHttpResponse("Aspfm.Login","Aspfm.Login.Login","login");
                MessageBox.Show(str);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
           
        }
        
    }
}